import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld/HelloWorld'
import HW_I from '@/components/HelloWorld/Index'
import Index from '@/components/Index'
// 改为这样：
// const index = () => import('@/components/index')

Vue.use(Router)

export function CreateRouter () {
  console.log('--------进入CreateRouter-------------')
  return new Router({
    mode: 'history',
    routes: [
      {
        path: '/',
        name: 'index',
        component: Index,
        alias: ['index.htm']
      },
      {
        path: '/index',
        name: 'index',
        component: Index,
        alias: ['/', '/index.html', '/index.php', '/index.jsp']
      },
      {
        path: '/HelloWorld',
        name: 'HW_I',
        component: HW_I,
        children: [
          {
            path: '/',
            name: 'HelloWorld',
            component: HelloWorld
          },
          {
            path: 'RenderMode',
            name: 'RenderMode',
            component: () => import('@/components/HelloWorld/RenderMode')
          },
          {
            path: 'Home',
            name: 'home',
            component: () => import('@/components/HelloWorld/Home')
          },
          {
            path: 'ArticlesView',
            name: 'articleView',
            component: () => import('@/components/HelloWorld/ArticlesView')
          },
          {
            path: 'Header',
            name: 'header',
            component: () => import('@/components/HelloWorld/Header')
          },
          {
            path: 'Articles',
            name: 'Articles',
            component: () => import('@/components/HelloWorld/Articles')
          },
          {
            path: 'Demo',
            name: 'HW_D_I',
            component: () => import('@/components/HelloWorld/Demo/Index'),
            children: [
              {
                path: '/',
                name: 'Demo',
                component: () => import('@/components/HelloWorld/Demo/Demo')
              },
              {
                path: 'Articles1',
                name: 'Articles',
                component: () => import('@/components/HelloWorld/Articles')
              },
              {
                path: 'Articles2',
                name: 'Articles',
                component: () => import('@/components/HelloWorld/Articles')
              }
            ]
          },
          {
            path: 'HelloWorldDemo',
            name: 'HelloWorldDemo',
            component: () => import('@/components/HelloWorld/HelloWorldDemo')
          },
          {
            path: 'Favicon',
            name: 'Favicon',
            component: () => import('@/components/HelloWorld/Favicon')
          },
          {
            path: 'Hello',
            name: 'Hello',
            component: () => import('@/components/HelloWorld/Hello')
          },
          {
            path: 'Hello2',
            name: 'Hello2',
            component: () => import('@/components/HelloWorld/Hello2')
          },
          {
            path: 'Hello3',
            name: 'Hello3',
            component: () => import('@/components/HelloWorld/Hello3')
          },
          {
            path: 'VueResourceComponents',
            name: 'VueResourceComponents',
            component: () => import('@/components/HelloWorld/VueResourceComponents')
          },
          {
            path: 'VueResourceComponents2',
            name: 'VueResourceComponents2',
            component: () => import('@/components/HelloWorld/VueResourceComponents2')
          }
        ]
      },
      {
        path: '/hello',
        name: 'hello',
        component: () => import('@/components/Hello')
      },
      {
        path: '/Hello/hello',
        name: 'hello',
        component: () => import('@/components/Hello')
      }
    ]
  })
}
